import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './index.less'
import { AtIcon } from 'taro-ui'
import api from '../../service/api'

export default class DoctorPage extends Component {

  config = {
    navigationBarTitleText: '医生主页'
  }

  constructor(){
    super(...arguments)
    this.state = {
        DoctorDetailData:[],
        currentTab: 1
    }
  }

  componentDidMount() {
    const params = {}
    params.userId = this.$router.params.id
    api.get('/inquiry/doctor/detail', params).then(res => {
        this.setState({
          DoctorDetailData: res.data.data
        })
    })
   }

   AskingQuestions(doctor) {
    Taro.navigateTo({
      url:`/pages/AskQuestion/index?name=`+ doctor.name + '&department=' + doctor.department + '&hospital=' + doctor.hospital + '&headImage=' + doctor.headImage + '&doctorId=' + doctor.userId
    })
  }


  render () {
    return (
      <View className='page'>
        <View className='page-top'>
          <Image className='page-top-doctorImg' src={DoctorDetailData.headImage}></Image>
          <View className='page-top-doctorName page-top-magin-5'>{DoctorDetailData.name}</View>
          <View className='page-top-doctorSubName page-top-magin-5'>
            {DoctorDetailData.doctorTitle}<Text>{DoctorDetailData.hospital}/{DoctorDetailData.department}</Text>
          </View>
          <View className='page-top-doctorTips'>{DoctorDetailData.description}</View>
        </View>
        <View className='page-main'>
          <View className='page-main-article'>
            <View className='page-main-article__h2'>
              <AtIcon prefixClass='icon' value='report' size='18' color='#4d484a'></AtIcon>
              &nbsp;问诊服务介绍
            </View>
            <View className='page-main-article__p'>
              <View>
                佑蜜医生均经过严格筛选。
              </View>
              <View>
                佑蜜专员实地验证其拥有卫计委颁发的《医师资格证》和《医师执业证》，以及所在医院的工作证。医生的具体咨询意见仅供参考。
              </View>
            </View>
            <View className='page-main-article__h2'>
              <AtIcon prefixClass='icon' value='human' size='18' color='#4d484a'></AtIcon>
              &nbsp;服务适合人群
            </View>
            <View className='page-main-article__p'>
              20岁-45岁的备孕女性
            </View>
            <View className='page-main-article__h2'>
              <AtIcon prefixClass='icon' value='time' size='18' color='#4d484a'></AtIcon>
              &nbsp;服务有效期
            </View>
            <View className='page-main-article__p'>
              每次问诊服务持续24小时，服务时间内有3次提问机会。
            </View>
          </View>
        </View>
        <View className='page-bottom'>
          <View className='page-bottom-btn' onClick={this.AskingQuestions.bind(this,DoctorDetailData)}>
            <View>
              <AtIcon prefixClass='icon' value='question' size='18' color='#fff'></AtIcon>
              &nbsp;我要问诊
            </View>
          </View>
        </View>
      </View>
    )
  }
}

